package cn.lf.controller;


import cn.lf.dto.sys.dict.SysDictTypeRepDTO;
import cn.lf.dto.sys.dict.SysDictTypeInfoDTO;
import cn.lf.dto.sys.dict.SysDictTypeReqDTO;
import cn.lf.dto.sys.dict.SysDictTypeSaveDTO;
import cn.lf.service.ISysDictTypeService;
import cn.lf.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 字典类型 前端控制器
 * </p>
 *
 * @author guoyy
 * @since 2024-04-03
 */
@RestController
@RequestMapping("/sys-dict-type")
@Api(tags = "字典类型管理")
public class SysDictTypeController {

    @Autowired
    private ISysDictTypeService sysDictTypeService;

    @GetMapping("/queryDictTypePage")
    @ApiOperation("获取字典类型分页")
    public ResponseModel<IPage<SysDictTypeRepDTO>> queryDictTypePage(SysDictTypeReqDTO params){

        IPage<SysDictTypeRepDTO> result = sysDictTypeService.queryDictTypePage(params);

        return ResponseModel.buildSuccessResult(result);
    }

    @GetMapping("/getSysDictTypeById")
    @ApiOperation("根据id获取字典类型")
    public ResponseModel<SysDictTypeInfoDTO> getSysDictTypeById(@RequestParam String dictTypeId){

        SysDictTypeInfoDTO result = sysDictTypeService.getSysDictTypeById(dictTypeId);

        return ResponseModel.buildSuccessResult(result);

    }

    @PostMapping("/saveSysDictType")
    @ApiOperation("保存或更新字典类型")
    public ResponseModel saveSysDictType(@RequestBody SysDictTypeSaveDTO sysDictTypeSaveDTO){

        sysDictTypeService.saveSysDictType(sysDictTypeSaveDTO);

        return ResponseModel.buildSuccessResult();
    }

    @GetMapping("/delSysDictType")
    @ApiOperation("删除字典类型")
    public ResponseModel delSysDictType(@RequestParam String dictTypeId){

        sysDictTypeService.delSysDictType(dictTypeId);

        return ResponseModel.buildSuccessResult();
    }



}
